#include "orangepch.h"
#include "Input.h"
#include "Orange/Application.h"
#include "GLFW/glfw3.h"
namespace Orange
{
    bool Input::IsKeyPressed(int keyCode)
    {
        GLFWwindow *window = static_cast<GLFWwindow *>(Application::Get().GetWindow().GetNativeWindow());
        int state = glfwGetKey(window, keyCode);

        return state == GLFW_PRESS || state == GLFW_REPEAT;
    };
    bool Input::IsMouseButtonPressed(int button)
    {
        GLFWwindow *window = static_cast<GLFWwindow *>(Application::Get().GetWindow().GetNativeWindow());
        int state = glfwGetMouseButton(window, button);

        return state == GLFW_PRESS;
    };
    std::pair<float, float> Input::GetMousePos()
    {
        GLFWwindow *window = static_cast<GLFWwindow *>(Application::Get().GetWindow().GetNativeWindow());

        double x, y;
        glfwGetCursorPos(window, &x, &y);

        return {(float)x, (float)y};
    };
    float Input::GetMousePosX()
    {
        auto [x, y] = GetMousePos();
        return x;
    };
    float Input::GetMousePosY()
    {
        auto [x, y] = GetMousePos();
        return y;
    };
}